import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @author zhaoqian
 * @create 2021/8/31 11:32
 */
public class k {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()){                  //求k个数
            String nextLine = in.nextLine();
            StringBuilder sb = new StringBuilder();
            String[] s = nextLine.split(" ");
            String nextLine2 = in.nextLine();
            String[] s1 = nextLine2.split(" ");
            ArrayList<Integer> list = new ArrayList<>();
            for (String q:s1) {
                Integer integer = Integer.valueOf(q);
                String s2 = String.valueOf(integer);
                list.add(integer);
            }
            list.sort(Comparator.naturalOrder());
            for (int i=0;i<Integer.valueOf(s[1]);i++){
                sb.append(list.get(i)).append(" ");
            }
            sb.deleteCharAt(sb.length()-1);
            String s2 = sb.toString();
            System.out.println(s2);
        }
    }
}
